#define _CRT_SECURE_NO_WARNINGS
//#include"SList.h"
//int main() {
//	SLNode* pplist = NULL;
//
//
//	return 0;
//}

#include<stdio.h>
#include<stdlib.h>
 struct ListNode {
      int val;
      struct ListNode *next;
  };

struct ListNode* removeElements(struct ListNode* head, int val) {
    struct ListNode* prev = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* cur = head;
    prev->next = cur;
    while (cur)
    {
        if (cur->val == val)
        {
            prev->next = cur->next;
            free(cur);
            cur = prev->next;
        }
        else
        {
            prev = cur;
            cur = cur->next;
        }
    }
    return head;
}
int main() {
    struct ListNode* l1 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* l2 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* l3 = (struct ListNode*)malloc(sizeof(struct ListNode));
    struct ListNode* l4 = (struct ListNode*)malloc(sizeof(struct ListNode));
    l1->val = 7;
    l2->val = 7;
    l3->val = 7;
    l4->val = 7;
    l1->next = l2;
    l2->next = l3;
    l3->next = l4;
    l4->next = NULL;
    struct ListNode*  ret=removeElements(l1,7);
    printf("%p\n",ret);
    return 0;
}